{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 10: Interoperability With Other Python Libraries"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Converting to and from a pandas DataFrame"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### How to do it..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import polars as pl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "polars.dataframe.frame.DataFrame"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pl.DataFrame({\n",
    "    'a': [1,2,3],\n",
    "    'b': [4,5,6]\n",
    "})\n",
    "\n",
    "type(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pandas_df = df.to_pandas()\n",
    "\n",
    "type(pandas_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    int64[pyarrow]\n",
       "b    int64[pyarrow]\n",
       "dtype: object"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_pandas(use_pyarrow_extension_array=True).dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "polars.dataframe.frame.DataFrame"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pl.from_pandas(pandas_df)\n",
    "type(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "polars.dataframe.frame.DataFrame"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(pl.DataFrame(pandas_df))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### There is more"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = pl.Series([1,2,3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.series.Series"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(s.to_pandas())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "polars.series.series.Series"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(pl.from_pandas(s.to_pandas()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Converting to and from NumPy arrays"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### How to do it..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "import polars as pl\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "arr = np.array([[1,2,3], [4,5,6]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (3, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>a</th><th>b</th></tr><tr><td>i64</td><td>i64</td></tr></thead><tbody><tr><td>1</td><td>4</td></tr><tr><td>2</td><td>5</td></tr><tr><td>3</td><td>6</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (3, 2)\n",
       "┌─────┬─────┐\n",
       "│ a   ┆ b   │\n",
       "│ --- ┆ --- │\n",
       "│ i64 ┆ i64 │\n",
       "╞═════╪═════╡\n",
       "│ 1   ┆ 4   │\n",
       "│ 2   ┆ 5   │\n",
       "│ 3   ┆ 6   │\n",
       "└─────┴─────┘"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pl.from_numpy(arr, schema=['a', 'b'], orient='col')\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 4],\n",
       "       [2, 5],\n",
       "       [3, 6]])"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_numpy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([(1, 4), (2, 5), (3, 6)], dtype=[('a', '<i8'), ('b', '<i8')])"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_numpy(structured=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (3, 3)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>a</th><th>b</th><th>gcd</th></tr><tr><td>i64</td><td>i64</td><td>i64</td></tr></thead><tbody><tr><td>1</td><td>4</td><td>1</td></tr><tr><td>2</td><td>5</td><td>1</td></tr><tr><td>3</td><td>6</td><td>3</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (3, 3)\n",
       "┌─────┬─────┬─────┐\n",
       "│ a   ┆ b   ┆ gcd │\n",
       "│ --- ┆ --- ┆ --- │\n",
       "│ i64 ┆ i64 ┆ i64 │\n",
       "╞═════╪═════╪═════╡\n",
       "│ 1   ┆ 4   ┆ 1   │\n",
       "│ 2   ┆ 5   ┆ 1   │\n",
       "│ 3   ┆ 6   ┆ 3   │\n",
       "└─────┴─────┴─────┘"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(\n",
    "    df\n",
    "    .with_columns(\n",
    "        np.gcd(pl.col('a'), pl.col('b')).alias('gcd')\n",
    "    )\n",
    "\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### There is more..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = pl.Series([1,2,3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 2, 3])"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.to_numpy()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Interoperating with PyArrow"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import polars as pl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pyarrow.Table\n",
       "Company: large_string\n",
       "Amount: large_string\n",
       "Lead investors: large_string\n",
       "Valuation: large_string\n",
       "Date reported: large_string\n",
       "Industry: string\n",
       "----\n",
       "Company: [[\"Restaurant365\"],[\"Madhive\"],...,[\"Indigo\"],[\"Chronosphere\"]]\n",
       "Amount: [[\"$135,000,000\"],[\"$300,000,000\"],...,[\"$250,000,000\"],[\"$115,000,000\"]]\n",
       "Lead investors: [[\"KKR, L Catterton\"],[\"Goldman Sachs Asset Management\"],...,[\"Flagship Pioneering, State of Michigan Retirement System, Lingotto\"],[\"GV\"]]\n",
       "Valuation: [[\"$1,000,000,000\"],[\"$1,000,000,000\"],...,[\"na\"],[\"n/a\"]]\n",
       "Date reported: [[\"5/19/23\"],[\"6/13/23\"],...,[\"9/15/23\"],[\"1/9/23\"]]\n",
       "Industry: [[\"Accounting\"],[\"Advertising\"],...,[\"Agriculture\"],[\"Analytics\"]]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyarrow.dataset as ds\n",
    "\n",
    "file_path = '../data/venture_funding_deals_partitioned'\n",
    "part = ds.partitioning(flavor='hive')\n",
    "dataset = ds.dataset(file_path, partitioning=part)\n",
    "\n",
    "dataset.head(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (5, 6)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>Company</th><th>Amount</th><th>Lead investors</th><th>Valuation</th><th>Date reported</th><th>Industry</th></tr><tr><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;Restaurant365&quot;</td><td>&quot;$135,000,000&quot;</td><td>&quot;KKR, L Cattert…</td><td>&quot;$1,000,000,000…</td><td>&quot;5/19/23&quot;</td><td>&quot;Accounting&quot;</td></tr><tr><td>&quot;Madhive&quot;</td><td>&quot;$300,000,000&quot;</td><td>&quot;Goldman Sachs …</td><td>&quot;$1,000,000,000…</td><td>&quot;6/13/23&quot;</td><td>&quot;Advertising&quot;</td></tr><tr><td>&quot;Ursa Major,&quot;</td><td>&quot;$100,000,000&quot;</td><td>&quot;BlackRock, Spa…</td><td>&quot;n/a&quot;</td><td>&quot;4/26/23&quot;</td><td>&quot;Aerospace&quot;</td></tr><tr><td>&quot;Indigo&quot;</td><td>&quot;$250,000,000&quot;</td><td>&quot;Flagship Pione…</td><td>&quot;na&quot;</td><td>&quot;9/15/23&quot;</td><td>&quot;Agriculture&quot;</td></tr><tr><td>&quot;Chronosphere&quot;</td><td>&quot;$115,000,000&quot;</td><td>&quot;GV&quot;</td><td>&quot;n/a&quot;</td><td>&quot;1/9/23&quot;</td><td>&quot;Analytics&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (5, 6)\n",
       "┌───────────────┬──────────────┬────────────────────┬────────────────┬───────────────┬─────────────┐\n",
       "│ Company       ┆ Amount       ┆ Lead investors     ┆ Valuation      ┆ Date reported ┆ Industry    │\n",
       "│ ---           ┆ ---          ┆ ---                ┆ ---            ┆ ---           ┆ ---         │\n",
       "│ str           ┆ str          ┆ str                ┆ str            ┆ str           ┆ str         │\n",
       "╞═══════════════╪══════════════╪════════════════════╪════════════════╪═══════════════╪═════════════╡\n",
       "│ Restaurant365 ┆ $135,000,000 ┆ KKR, L Catterton   ┆ $1,000,000,000 ┆ 5/19/23       ┆ Accounting  │\n",
       "│ Madhive       ┆ $300,000,000 ┆ Goldman Sachs      ┆ $1,000,000,000 ┆ 6/13/23       ┆ Advertising │\n",
       "│               ┆              ┆ Asset Management   ┆                ┆               ┆             │\n",
       "│ Ursa Major,   ┆ $100,000,000 ┆ BlackRock, Space   ┆ n/a            ┆ 4/26/23       ┆ Aerospace   │\n",
       "│               ┆              ┆ Capital            ┆                ┆               ┆             │\n",
       "│ Indigo        ┆ $250,000,000 ┆ Flagship           ┆ na             ┆ 9/15/23       ┆ Agriculture │\n",
       "│               ┆              ┆ Pioneering, State  ┆                ┆               ┆             │\n",
       "│               ┆              ┆ of Mi…             ┆                ┆               ┆             │\n",
       "│ Chronosphere  ┆ $115,000,000 ┆ GV                 ┆ n/a            ┆ 1/9/23        ┆ Analytics   │\n",
       "└───────────────┴──────────────┴────────────────────┴────────────────┴───────────────┴─────────────┘"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pl.from_arrow(dataset.to_table())  \n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pyarrow.Table\n",
       "Company: large_string\n",
       "Amount: large_string\n",
       "Lead investors: large_string\n",
       "Valuation: large_string\n",
       "Date reported: large_string\n",
       "Industry: large_string\n",
       "----\n",
       "Company: [[\"Restaurant365\",\"Madhive\",\"Ursa Major,\",\"Indigo\",\"Chronosphere\",...,\"Professional Fighters League\",\"Newlight Technologies\",\"Pivotal Commware\",\"Via\",\"Aquaback Technologies\"]]\n",
       "Amount: [[\"$135,000,000\",\"$300,000,000\",\"$100,000,000\",\"$250,000,000\",\"$115,000,000\",...,\"$100,000,000\",\"$125,000,000\",\"$102,000,000\",\"$110,000,000\",\"$110,000,000\"]]\n",
       "Lead investors: [[\"KKR, L Catterton\",\"Goldman Sachs Asset Management\",\"BlackRock, Space Capital\",\"Flagship Pioneering, State of Michigan Retirement System, Lingotto\",\"GV\",...,\"SRJ Sports Investments\",\"GenZero\",\"Gates Frontier, Tracker Capital\",\"83North\",\"Global Emerging Markets Group\"]]\n",
       "Valuation: [[\"$1,000,000,000\",\"$1,000,000,000\",\"n/a\",\"na\",\"n/a\",...,\"n/a\",\"n/a\",\"n/a\",\"$3,500,000,000\",\"n/a\"]]\n",
       "Date reported: [[\"5/19/23\",\"6/13/23\",\"4/26/23\",\"9/15/23\",\"1/9/23\",...,\"8/30/23\",\"8/3/23\",\"8/17/23\",\"2/13/23\",\"6/28/23\"]]\n",
       "Industry: [[\"Accounting\",\"Advertising\",\"Aerospace\",\"Agriculture\",\"Analytics\",...,\"Sports\",\"Sustainability\",\"Telecommunications\",\"Transportation\",\"Water\"]]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_arrow()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (5, 6)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>Company</th><th>Amount</th><th>Lead investors</th><th>Valuation</th><th>Date reported</th><th>Industry</th></tr><tr><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;Restaurant365&quot;</td><td>&quot;$135,000,000&quot;</td><td>&quot;KKR, L Cattert…</td><td>&quot;$1,000,000,000…</td><td>&quot;5/19/23&quot;</td><td>&quot;Accounting&quot;</td></tr><tr><td>&quot;Madhive&quot;</td><td>&quot;$300,000,000&quot;</td><td>&quot;Goldman Sachs …</td><td>&quot;$1,000,000,000…</td><td>&quot;6/13/23&quot;</td><td>&quot;Advertising&quot;</td></tr><tr><td>&quot;Ursa Major,&quot;</td><td>&quot;$100,000,000&quot;</td><td>&quot;BlackRock, Spa…</td><td>&quot;n/a&quot;</td><td>&quot;4/26/23&quot;</td><td>&quot;Aerospace&quot;</td></tr><tr><td>&quot;Indigo&quot;</td><td>&quot;$250,000,000&quot;</td><td>&quot;Flagship Pione…</td><td>&quot;na&quot;</td><td>&quot;9/15/23&quot;</td><td>&quot;Agriculture&quot;</td></tr><tr><td>&quot;Chronosphere&quot;</td><td>&quot;$115,000,000&quot;</td><td>&quot;GV&quot;</td><td>&quot;n/a&quot;</td><td>&quot;1/9/23&quot;</td><td>&quot;Analytics&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (5, 6)\n",
       "┌───────────────┬──────────────┬────────────────────┬────────────────┬───────────────┬─────────────┐\n",
       "│ Company       ┆ Amount       ┆ Lead investors     ┆ Valuation      ┆ Date reported ┆ Industry    │\n",
       "│ ---           ┆ ---          ┆ ---                ┆ ---            ┆ ---           ┆ ---         │\n",
       "│ str           ┆ str          ┆ str                ┆ str            ┆ str           ┆ str         │\n",
       "╞═══════════════╪══════════════╪════════════════════╪════════════════╪═══════════════╪═════════════╡\n",
       "│ Restaurant365 ┆ $135,000,000 ┆ KKR, L Catterton   ┆ $1,000,000,000 ┆ 5/19/23       ┆ Accounting  │\n",
       "│ Madhive       ┆ $300,000,000 ┆ Goldman Sachs      ┆ $1,000,000,000 ┆ 6/13/23       ┆ Advertising │\n",
       "│               ┆              ┆ Asset Management   ┆                ┆               ┆             │\n",
       "│ Ursa Major,   ┆ $100,000,000 ┆ BlackRock, Space   ┆ n/a            ┆ 4/26/23       ┆ Aerospace   │\n",
       "│               ┆              ┆ Capital            ┆                ┆               ┆             │\n",
       "│ Indigo        ┆ $250,000,000 ┆ Flagship           ┆ na             ┆ 9/15/23       ┆ Agriculture │\n",
       "│               ┆              ┆ Pioneering, State  ┆                ┆               ┆             │\n",
       "│               ┆              ┆ of Mi…             ┆                ┆               ┆             │\n",
       "│ Chronosphere  ┆ $115,000,000 ┆ GV                 ┆ n/a            ┆ 1/9/23        ┆ Analytics   │\n",
       "└───────────────┴──────────────┴────────────────────┴────────────────┴───────────────┴─────────────┘"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lf = pl.scan_pyarrow_dataset(dataset)\n",
    "lf.head().collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pyarrow.lib.LargeStringArray object at 0x12fd3d9c0>\n",
       "[\n",
       "  \"Restaurant365\",\n",
       "  \"Madhive\",\n",
       "  \"Ursa Major,\",\n",
       "  \"Indigo\",\n",
       "  \"Chronosphere\",\n",
       "  \"AlphaSense\",\n",
       "  \"Skims\",\n",
       "  \"SandboxAQ\",\n",
       "  \"Humane\",\n",
       "  \"OpenAI\",\n",
       "  ...\n",
       "  \"Eagle Eye Networks\",\n",
       "  \"Enfabrica\",\n",
       "  \"Axiom Space\",\n",
       "  \"Sierra Space\",\n",
       "  \"Astranis\",\n",
       "  \"Professional Fighters League\",\n",
       "  \"Newlight Technologies\",\n",
       "  \"Pivotal Commware\",\n",
       "  \"Via\",\n",
       "  \"Aquaback Technologies\"\n",
       "]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(\n",
    "    lf\n",
    "    .select('Company')\n",
    "    .collect()\n",
    "    .to_series()\n",
    "    .to_arrow()\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Integration with DuckDB"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### How to do it..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import polars as pl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "┌───────┐\n",
      "│   a   │\n",
      "│ int64 │\n",
      "├───────┤\n",
      "│     1 │\n",
      "│     2 │\n",
      "│     3 │\n",
      "└───────┘\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import duckdb \n",
    "\n",
    "df = pl.DataFrame({\n",
    "    'a': [1,2,3]\n",
    "})\n",
    "\n",
    "rel = duckdb.sql('SELECT * FROM df')\n",
    "rel.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (3, 1)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>a</th></tr><tr><td>i64</td></tr></thead><tbody><tr><td>1</td></tr><tr><td>2</td></tr><tr><td>3</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (3, 1)\n",
       "┌─────┐\n",
       "│ a   │\n",
       "│ --- │\n",
       "│ i64 │\n",
       "╞═════╡\n",
       "│ 1   │\n",
       "│ 2   │\n",
       "│ 3   │\n",
       "└─────┘"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rel.pl()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.3"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
